// Author: wsfuyibing <682805@qq.com>
// Date: 2025-04-27

package config

import (
	"gitee.com/go-libs/config"
)

// Arcade
// 钓场配置实例.
var Arcade ArcadeConfig

const (
	defaultArcadeHeaderName  = "X-Arcade"
	defaultArcadeSwiperCount = 3
	defaultArcadePondCount   = 3
	defaultArcadeSeatCount   = 300
)

type (
	// ArcadeConfig
	// 钓场配置接口.
	ArcadeConfig interface {
		GetHeaderName() string
		GetSwiperCount() int
		GetPondCount() int
		GetSeatCount() int
	}

	arcadeConfig struct {
		HeaderName string `yaml:"header-name"`

		// PondCount
		// 钓场最多可以设置多少张轮播图.
		SwiperCount int `yaml:"swiper-count"`

		// PondCount
		// 钓场最多可以设置多少个鱼塘.
		PondCount int `yaml:"pond-count"`

		// SeatCount
		// 鱼塘最多可以设置多少个钓位.
		SeatCount int `yaml:"seat-count"`
	}
)

// +---------------------------------------------------------------------------+
// | Interface methods                                                         |
// +---------------------------------------------------------------------------+

func (o *arcadeConfig) GetHeaderName() string { return o.HeaderName }
func (o *arcadeConfig) GetSwiperCount() int   { return o.SwiperCount }
func (o *arcadeConfig) GetPondCount() int     { return o.PondCount }
func (o *arcadeConfig) GetSeatCount() int     { return o.SeatCount }

// +---------------------------------------------------------------------------+
// | Hook methods                                                              |
// +---------------------------------------------------------------------------+

func (o *arcadeConfig) After() {
	if o.HeaderName == "" {
		o.HeaderName = defaultArcadeHeaderName
	}
	if o.SwiperCount == 0 {
		o.SwiperCount = defaultArcadeSwiperCount
	}
	if o.PondCount == 0 {
		o.PondCount = defaultArcadePondCount
	}
	if o.SeatCount == 0 {
		o.SeatCount = defaultArcadeSeatCount
	}
}

// +---------------------------------------------------------------------------+
// | Access methods                                                            |
// +---------------------------------------------------------------------------+

func (o *arcadeConfig) init() *arcadeConfig {
	_ = config.Seek("arcade.yaml", "arcade.yml").ScanYaml(o)
	return o
}
